<template>
    <div class="control-check">
        <div class="check1">
            <el-button type="primary" @click="lookControl = true">查询</el-button>
            <el-button type="primary" @click="resetData">刷新</el-button>
            <el-button type="primary" v-authCode.show="B_0024" @click="reCheck('1')">复核通过</el-button>
            <el-button type="danger" v-authCode.show="B_0025" @click="reCheck('2')">复核拒绝</el-button>
            <el-button type="primary" v-authCode.show="B_0026" @click="layoutDialog = true">布局设置</el-button>
        </div>
        <div class="check2">
            <el-table
                :data="tableData"
                tooltip-effect="dark"
                style="width: 100%"
                border
                size="mini"
                height="68vh"
                ref="table"
                @row-dblclick="rowClick"
                v-loading="loading"
                :row-style="isRed"
            >
                <RiskTableSelection
                    row-key="entryCode"
                    :current-page-table-list="tableData"
                    :selected="selectedList"
                    show-drop-down
                    :drop-down-list="[{ text: '选择全部', value: 'all' }]"
                    @dropdown-click="dropdownClick"
                    :disabledMethod="disabledMethod"
                    width="60"
                />
                <el-table-column label="条目编号" width="120" prop="entryCode" fixed="left" show-overflow-tooltip> </el-table-column>
                <el-table-column label="复核状态" width="120" prop="modifyStatus" fixed="left" show-overflow-tooltip>
                    <template slot-scope="scope">
                        <span v-if="scope.row.modifyStatus === '1'">待复核</span>
                        <span v-else-if="scope.row.modifyStatus === '2'">复核通过</span>
                        <span v-else-if="scope.row.modifyStatus === '3'">复核拒绝</span>
                        <span v-else-if="scope.row.modifyStatus === '4'">废弃</span>
                    </template>
                </el-table-column>
                <el-table-column label="事件" width="120" fixed="left" show-overflow-tooltip>
                    <template slot-scope="scope">
                        <span v-if="scope.row.modifyType === '1'" style="color: blue">新增条目</span>
                        <span v-else-if="scope.row.modifyType === '2'" style="color: green">修改条目</span>
                        <span v-else-if="scope.row.modifyType === '3'" style="color: red">删除条目</span>
                        <span v-else-if="scope.row.modifyType === '4'" style="color: red">状态修改</span>
                        <span v-else-if="scope.row.modifyType === '5'" style="color: green">条目同步</span>
                    </template>
                </el-table-column>
                <el-table-column
                    v-for="(col, index) in showColumns"
                    :key="index"
                    :prop="col.prop"
                    :label="col.title"
                    :width="col.width"
                    show-overflow-tooltip
                >
                    <template slot-scope="scope">
                        <span v-if="col.funcBody">
                            {{ col.funcBody(scope.row[col.prop], scope.row) }}
                        </span>
                        <span v-else v-html="getTbalesData(scope.row, col.prop)"></span>
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="240" fixed="right">
                    <template slot-scope="scope">
                        <RiskIconButton
                            type="primary"
                            v-authCode="B_0022"
                            icon="el-icon-view"
                            topTitle="查看条目"
                            size="mini"
                            @on-click="openTabs('lookCheck', scope.row)"
                        ></RiskIconButton>
                        <RiskIconButton
                            type="primary"
                            v-authCode="B_0021"
                            icon="el-icon-edit"
                            topTitle="编辑条目"
                            :disabled="
                                scope.row.modifyType === '3' ||
                                (userInfo.superuser == true ? false : userInfo.userCode == scope.row.modifyUserCode ? false : true)
                            "
                            size="mini"
                            @on-click="openTabs('editCheck', scope.row)"
                        ></RiskIconButton>
                        <RiskIconButton
                            type="primary"
                            v-authCode="B_0024"
                            icon="el-icon-circle-check"
                            topTitle="复核通过"
                            :disabled="
                                (scope.row.modifyStatus === '1' ? false : true) ||
                                (userInfo.superuser == true ? false : userInfo.userCode == scope.row.modifyUserCode ? true : false)
                            "
                            size="mini"
                            @on-click="reviewer('1', scope.row)"
                        ></RiskIconButton>
                        <RiskIconButton
                            :disabled="scope.row.useO32Cal"
                            type="primary"
                            v-authCode="B_0023"
                            icon="el-icon-set-up"
                            topTitle="条目校验"
                            size="mini"
                            @on-click="verifyInfo(scope.row)"
                        ></RiskIconButton>
                        <RiskIconButton
                            type="danger"
                            v-authCode="B_0025"
                            icon="el-icon-circle-close"
                            topTitle="复核拒绝"
                            :disabled="scope.row.modifyStatus === '1' ? false : true"
                            size="mini"
                            @on-click="reviewer('2', scope.row)"
                        ></RiskIconButton>
                    </template>
                </el-table-column>
            </el-table>
            <div class="block">
                <risk-pagination :paging="paging" @page-change="currentChange"></risk-pagination>
            </div>
            <!-- <yh-dialog :title="dialogTitle" :visible.sync="lookCheck" width="600px" v-loading="loading" drag>
                <div>
                    {{ selectedList.map(item => item).join(',') }}
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button size="mini" @click="lookCheck = false">取 消</el-button>
                    <el-button size="mini" type="primary" @click="reCheckReset">确 定 </el-button>
                </div>
            </yh-dialog> -->

            <el-dialog :title="verificationTitle" :visible.sync="verification" width="600px" v-loading="loading">
                <div style="overflow: auto">
                    <div>
                        <span style="color: green; font-size: 15px; margin-bottom: 5px">修改条目编号汇总：</span>
                        <span style="color: red" v-for="(item, index) in selectedArrListChild" :key="index"
                            >{{ item.entryCode }} {{ index == selectedArrListChild.length - 1 ? '' : ',' }}</span
                        >
                    </div>
                    <div class="edit-div" v-for="(item, index) in editDatas" :key="index">
                        <div>
                            <div style="font-size: 15px; margin-bottom: 2px">【条目编号】</div>
                            <div style="color: green; margin-left: 20px">{{ selectedArrListChild[index].entryCode }}</div>
                        </div>
                        <EntryItemCompare v-if="item.EntryControl && item.EntryControl.length > 0" title="条目基本信息" :data="item.EntryControl" />
                        <EntryItemCompare v-if="item.EntryBranch && item.EntryBranch.length > 0" title="条目分支信息" :data="item.EntryBranch" />
                        <EntryItemCompare
                            v-if="item.EntryBranchConfig && item.EntryBranchConfig.length > 0"
                            title="条目分支范围配置信息"
                            :data="item.EntryBranchConfig"
                        />
                        <EntryItemCompare
                            v-if="item.RiskEntryParam && item.RiskEntryParam.length > 0"
                            title="高级设置信息"
                            :data="item.RiskEntryParam"
                        />
                        <EntryItemCompare
                            v-if="item.EntryFundConfig && item.EntryFundConfig.length > 0"
                            title="基金范围信息"
                            :data="item.EntryFundConfig"
                        />
                        <EntryItemCompare
                            v-if="item.RiskCustomResidualMaturity && item.RiskCustomResidualMaturity.length > 0"
                            title="条目自定义设置-剩余期限参数"
                            :data="item.RiskCustomResidualMaturity"
                        />
                        <EntryItemCompare
                            v-if="item.RiskCustomApprovalTier && item.RiskCustomApprovalTier.length > 0"
                            title="条目自定义设置-审批层级参数设置"
                            :data="item.RiskCustomApprovalTier"
                        />
                        <EntryItemCompare
                            v-if="item.RegulationsPublicOffering && item.RegulationsPublicOffering.length > 0"
                            title="条目自定义设置-法规公募"
                            :data="item.RegulationsPublicOffering"
                        />
                        <EntryItemCompare
                            v-if="item.RegulationsOnlyDoorGather && item.RegulationsOnlyDoorGather.length > 0"
                            title="条目自定义设置-法规专户(集合)"
                            :data="item.RegulationsOnlyDoorGather"
                        />
                        <EntryItemCompare
                            v-if="item.RegulationsOnlyDoorSingle && item.RegulationsOnlyDoorSingle.length > 0"
                            title="条目自定义设置-法规专户(单一)"
                            :data="item.RegulationsOnlyDoorSingle"
                        />
                        <EntryItemCompare
                            v-if="item.JoinRiskEntryControls && item.JoinRiskEntryControls.length > 0"
                            title="条目关联"
                            :data="item.JoinRiskEntryControls"
                        />
                        <EntryItemCompare
                            v-if="item.MutualRiskEntryControls && item.MutualRiskEntryControls.length > 0"
                            title="条目互斥"
                            :data="item.MutualRiskEntryControls"
                        />
                        <EntryItemCompare
                            v-if="item.PremiseRiskEntryControls && item.PremiseRiskEntryControls.length > 0"
                            title="前提条目"
                            :data="item.PremiseRiskEntryControls"
                        />
                        <EntryItemCompare
                            v-if="item.ConsecutiveViolationDays && item.ConsecutiveViolationDays.length > 0"
                            title="连续违规天数"
                            :data="item.ConsecutiveViolationDays"
                        />
                        <hr style="margin: 10px 0; color: #e8e8e8" />
                    </div>
                    <div>
                        <p style="font-size: 15px; padding-bottom: 5px">【备注原因】</p>
                        <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" placeholder="请备注原因" v-model="checkReason"> </el-input>
                    </div>
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button size="mini" @click="verification = false">取 消</el-button>
                    <el-button size="mini" type="primary" @click="reCheckReset">确 定 </el-button>
                </div>
            </el-dialog>

            <el-dialog
                title="查询条目信息"
                :visible.sync="lookControl"
                width="680px"
                v-loading="loading"
                drag
                :close-on-click-modal="false"
                :close-on-press-escape="false"
            >
                <div class="con-select-div">
                    <div class="divs">
                        <div class="divs-left">
                            <span>条目编号</span>
                            <el-input
                                class="divs-left-input"
                                size="mini"
                                v-model="entryCodeLits"
                                @input="changEntrycode(entryCodeLits)"
                                placeholder="支持','分割"
                            />
                            <el-checkbox
                                size="mini"
                                label="准确搜索"
                                style="margin-left: 9px; width: 129px"
                                v-model="selectData.precision"
                                border
                            ></el-checkbox>
                        </div>
                        <div class="divs-right">
                            <span>作用范围</span>
                            <el-select size="mini" multiple collapse-tags v-model="selectData.riskCalTypes" class="ringt-input">
                                <el-option value="0" label="静态"></el-option>
                                <el-option value="1" label="指令"></el-option>
                            </el-select>
                        </div>
                    </div>
                    <div class="divs">
                        <div class="divs-left">
                            <span>风险说明</span>
                            <el-input class="divs-left-input1" v-model="selectData.entryName" size="mini" />
                        </div>
                        <div class="divs-right">
                            <span>启用状态</span>
                            <el-select size="mini" v-model="selectData.entryStatuss" multiple collapse-tags class="ringt-input">
                                <el-option value="0" label="禁用"></el-option>
                                <el-option value="1" label="启用"></el-option>
                            </el-select>
                        </div>
                    </div>
                    <div class="divs">
                        <div class="divs-left">
                            <span>风险等级</span>
                            <el-select class="left-input2" v-model="selectData.controlGrades" size="mini" multiple collapse-tags placeholder="请选择">
                                <el-option
                                    v-for="itme in computedAlertControlGrade"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKeyName"
                                ></el-option>
                            </el-select>
                            <span class="span-left">生效时间</span>
                            <el-date-picker
                                class="left-input2"
                                v-model="selectData.beginDate"
                                type="date"
                                format="yyyy-MM-dd"
                                value-format="yyyyMMdd"
                                size="mini"
                                style="width: 130px"
                            ></el-date-picker>
                        </div>
                        <div class="divs-right">
                            <span>失效时间</span>
                            <el-date-picker
                                class="ringt-input"
                                v-model="selectData.endDate"
                                type="date"
                                format="yyyy-MM-dd"
                                value-format="yyyyMMdd"
                                size="mini"
                                style="width: 130px"
                            ></el-date-picker>
                        </div>
                    </div>
                    <div class="divs">
                        <div class="divs-left">
                            <span>基金账户</span>
                            <el-select
                                class="left-input2"
                                v-model="selectData.accountControlValue"
                                size="mini"
                                multiple
                                collapse-tags
                                placeholder="请选择"
                            >
                                <el-option v-for="itme in computedAccountList" :key="itme.id" :value="itme.id" :label="itme.label"></el-option>
                            </el-select>
                            <!-- <span class="span-left">条目来源</span>
                            <el-select class="left-input2" v-model="selectData.sourceType" size="mini" multiple collapse-tags placeholder="请选择">
                                <el-option value="1" label="本地"></el-option>
                                <el-option value="2" label="恒生-主动"></el-option>
                                <el-option value="5" label="恒生-被动"></el-option>
                            </el-select>

                        </div>
                        <div class="divs-right">
                            <span>风险类型</span>
                            <el-select class="ringt-input" v-model="selectData.entryTypes" size="mini" multiple collapse-tags placeholder="请选择">
                                <el-option
                                    v-for="itme in EntryTypeList"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKeyName"
                                ></el-option>
                            </el-select>
                        </div>
                    </div> -->
                            <span class="span-left">{{ SHOW_SECURITY ? '投资组合' : '条目来源' }}</span>
                            <el-select
                                class="left-input2"
                                v-model="selectData.sourceType"
                                size="mini"
                                multiple
                                collapse-tags
                                placeholder="请选择"
                                v-show="!SHOW_SECURITY"
                            >
                                <el-option
                                    v-for="item in computedSourceTypes"
                                    :key="item.dictKey"
                                    :value="item.dictKey"
                                    :label="item.dictKeyName"
                                ></el-option>
                            </el-select>
                            <el-select
                                class="left-input2"
                                v-model="selectData.fdAcCodeControlValue"
                                size="mini"
                                multiple
                                filterable
                                :filter-method="filterMethodFdAc"
                                @visible-change="handleVisibleChange"
                                clearable
                                collapse-tags
                                placeholder="请选择"
                                v-show="SHOW_SECURITY"
                            >
                                <el-option
                                    v-for="itme in computedFilterfdAcList"
                                    :key="itme.fundAccountCode"
                                    :value="itme.fundAccountCode"
                                    :label="itme.fundAccountCode + '-' + itme.fundAccountName"
                                ></el-option>
                            </el-select>
                        </div>
                        <div class="divs-right">
                            <span>{{ SHOW_SECURITY ? '资产单元' : '风险类型' }}</span>
                            <el-select
                                class="ringt-input"
                                v-model="selectData.entryTypes"
                                size="mini"
                                multiple
                                collapse-tags
                                placeholder="请选择"
                                v-show="!SHOW_SECURITY"
                            >
                                <el-option
                                    v-for="itme in computedEntryTypeList"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKeyName"
                                ></el-option>
                            </el-select>
                            <el-select
                                style="width: 133px"
                                v-model="selectData.assetCodeControlValue"
                                size="mini"
                                multiple
                                filterable
                                :filter-method="filterMethodAsset"
                                @visible-change="handleVisibleChange"
                                clearable
                                collapse-tags
                                placeholder="请选择"
                                v-show="SHOW_SECURITY"
                            >
                                <el-option
                                    v-for="itme in computedFilterAssetList"
                                    :key="itme.assetCode"
                                    :value="itme.assetCode"
                                    :label="itme.assetCode + '-' + itme.assetName"
                                ></el-option>
                            </el-select>
                        </div>
                    </div>
                    <div class="divs" v-show="SHOW_SECURITY">
                        <div class="divs-left">
                            <span>条目来源</span>
                            <el-select class="left-input2" v-model="selectData.sourceType" size="mini" multiple collapse-tags placeholder="请选择">
                                <el-option
                                    v-for="item in computedSourceTypes"
                                    :key="item.dictKey"
                                    :value="item.dictKey"
                                    :label="item.dictKeyName"
                                ></el-option>
                            </el-select>

                            <span class="span-left"> 风险类型</span>
                            <el-select class="left-input2" v-model="selectData.entryTypes" size="mini" multiple collapse-tags placeholder="请选择">
                                <el-option
                                    v-for="itme in computedEntryTypeList"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKeyName"
                                ></el-option>
                            </el-select>
                        </div>
                        <!-- <div class="divs-right">
                                <span>资产单元</span>
                                <el-select
                                    class="ringt-input"
                                    v-model="selectData.assetCodeControlValue"
                                    size="mini"
                                    multiple
                                    filterable
                                    clearable
                                    collapse-tags
                                    placeholder="请选择"
                                >
                                    <el-option v-for="itme in accountList" :key="itme.id" :value="itme.id" :label="itme.label"></el-option>
                                </el-select>
                            </div> -->
                    </div>
                    <div class="divs">
                        <div class="divs-left">
                            <span>&nbsp;&nbsp;&nbsp;条目组</span>
                            <el-select style="width: 198px" v-model="selectData.entryGroups" size="mini" multiple collapse-tags placeholder="请选择">
                                <el-option
                                    v-for="itme in computedEntryGroupsList"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKey + itme.dictKeyName"
                                ></el-option>
                            </el-select>
                            <el-checkbox
                                size="mini"
                                style="margin-left: 8px; width: 130px"
                                v-model="selectData.excludeEntryGroup"
                                label="排除选中"
                                border
                            ></el-checkbox>
                        </div>
                        <div class="divs-right">
                            <span>自定义分类</span>
                            <el-select class="ringt-input" v-model="selectData.customType" size="mini" multiple collapse-tags placeholder="请选择">
                                <el-option
                                    v-for="itme in computedCustomTypesList"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKeyName"
                                ></el-option>
                            </el-select>
                        </div>
                    </div>
                    <div class="divs">
                        <div class="divs-left">
                            <span>&nbsp;&nbsp;&nbsp;复核人</span>
                            <el-select
                                class="left-input2"
                                v-model="selectData.checkUserCodes"
                                size="mini"
                                multiple
                                filterable
                                collapse-tags
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="itme in computedUserAccount"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKey + ' ' + itme.dictKeyName"
                                ></el-option>
                            </el-select>
                            <span class="span-left">复核时间</span>
                            <el-select
                                class="left-input2"
                                style="margin-left: 2px"
                                v-model="selectData.checkTableDataDirection"
                                clearable
                                size="mini"
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="itme in ControlDirection"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKey + itme.dictKeyName"
                                ></el-option>
                            </el-select>
                        </div>
                        <div class="divs-right2">
                            <el-date-picker
                                v-model="selectData.checkDate"
                                type="date"
                                format="yyyy-MM-dd"
                                value-format="yyyyMMdd"
                                size="mini"
                                style="width: 210px"
                            ></el-date-picker>
                        </div>
                    </div>
                    <div class="divs">
                        <div class="divs-left">
                            <span>复核事件</span>
                            <el-select
                                class="left-input2"
                                v-model="selectData.RiskModifyTypes"
                                size="mini"
                                multiple
                                collapse-tags
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="itme in computedRiskModifyType"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKey + itme.dictKeyName"
                                ></el-option>
                            </el-select>
                            <span class="span-left">复核状态</span>
                            <el-select
                                class="left-input2"
                                v-model="selectData.modifyStatusTypes"
                                size="mini"
                                multiple
                                collapse-tags
                                placeholder="请选择"
                            >
                                <el-option
                                    v-for="itme in computedModifyStatusTypes"
                                    :key="itme.dictKey"
                                    :value="itme.dictKey"
                                    :label="itme.dictKey + itme.dictKeyName"
                                ></el-option>
                            </el-select>
                        </div>
                    </div>
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button size="mini" @click="controlReset">重置</el-button>
                    <el-button size="mini" @click="lookControl = false">取 消</el-button>
                    <el-button size="mini" type="primary" @click="selectDatas">确 定 </el-button>
                </div>
            </el-dialog>
            <!-- <div>
                <el-drawer :visible.sync="drawer" direction="btt" size="40%">
                    <div class="aletr-tbale">
                        <el-table :data="mutextableData" tooltip-effect="dark" style="width: 100%" height="200px" border size="mini">
                            <el-table-column label="条目编号" width="120" prop="entryCode" fixed="left" show-overflow-tooltip> </el-table-column>
                            <el-table-column label="关联类型" width="120" prop="relationType" fixed="left" show-overflow-tooltip></el-table-column>
                            <el-table-column
                                :key="col.prop"
                                :prop="col.prop"
                                :label="col.title"
                                :width="col.width"
                                show-overflow-tooltip
                                v-for="col in Columns"
                            >
                                <template slot-scope="scope">
                                    <span v-if="col.funcBody"> {{ col.funcBody(scope.row[col.prop], scope.row) }} </span>
                                    <span v-else v-html="getTbalesData(scope.row, col.prop)"></span>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </el-drawer>
            </div> -->
        </div>
        <RiskTableLayout
            title="页面布局"
            :visible.sync="layoutDialog"
            :field-list="SHOW_SECURITY ? Columns.concat(otherTableColumns) : Columns"
            :selected-field-list="selectedFieldList"
            :fixed-field-list="fixedFieldList"
            table-name="RISK_ENTRT_CHECK"
            @on-submit="onSubmit"
        />
    </div>
</template>
<script lang="ts">
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
import RiskIconButton from '@/common/components/risk-icon-button.vue';
import { mixins } from 'vue-class-component';
import RiskEmitter from '@/common/mixis/risk-emitter.vue';
import { getCurrentPageData, timeFormat, dateFormat, numberFormat, unitShow, getConfigItem, changeOptions } from '@/utils/tools';
import DictionConstUtil, { awaitAxios, SGU_CACHE } from '@/utils/diction-const-util';
import RiskTableLayout from '@/common/components/risk-table-layout.vue';
import { getUser } from '@/utils/user-util';
import { IUserInfo, UserModule } from '@/store/modules/user';
import EntryItemCompare from './item-compare.vue';
import RiskPagination from '@/common/components/risk-pagination.vue';
@Component({
    name: 'RiskControlCheck',
    components: {
        RiskIconButton,
        RiskTableLayout,
        EntryItemCompare,
        RiskPagination,
    },
})
export default class RiskControlCheck extends mixins(RiskEmitter) {
    @Prop() editableTabsValue!: string;
    SHOW_SECURITY = getConfigItem('SHOW_SECURITY');
    // 复核通过按钮的需要用到的数据
    table2Data: any[] = [];
    tableData: any[] = [];
    timeFormat = timeFormat;
    dateFormat = dateFormat;
    Columns: any[] = [
        {
            title: '风险说明',
            prop: 'entryName',
            width: 250,
        },
        {
            title: '变动序号',
            prop: 'changeNo',
            width: 80,
        },
        {
            title: '风险类型',
            prop: 'entryType',
            width: 130,
        },
        {
            title: '生效日期',
            prop: 'beginDate',
            width: 100,
        },
        {
            title: '失效日期',
            prop: 'endDate',
            width: 100,
        },
        {
            title: '优先级',
            prop: 'level',
            width: 65,
        },
        {
            title: '状态',
            prop: 'entryStatusValid',
            width: 50,
        },
        {
            title: '风险等级',
            prop: 'controlGrade',
            width: 85,
        },
        {
            title: '作用范围',
            prop: 'riskCalTypes',
            width: 100,
        },
        {
            title: '阈值类型1',
            prop: 'thresholdType1',
            width: 100,
        },
        {
            title: '阈值1',
            prop: 'thresholdValue1',
            width: 100,
            funcBody: (value, record) => (value ? this.thresholdTypeFormat(value, record.unit) : ''),
        },
        {
            title: '阈值类型2',
            prop: 'thresholdType2',
            width: 100,
        },
        {
            title: '阈值2',
            prop: 'thresholdValue2',
            width: 100,
            funcBody: (value, record) => (value ? this.thresholdTypeFormat(value, record.unit) : ''),
        },
        {
            title: '阈值类型3',
            prop: 'thresholdType3',
            width: 100,
        },
        {
            title: '阈值3',
            prop: 'thresholdValue3',
            width: 100,
            funcBody: (value, record) => (value ? this.thresholdTypeFormat(value, record.unit) : ''),
        },
        {
            title: '静态控制值',
            prop: 'saThresholdValue',
            width: 160,
            funcBody: (value, record) => (value ? this.thresholdTypeFormat(value, record.unit) : ''),
        },
        // {
        //     title: '静态触警操作',
        //     prop: 'saThresholdType',
        //     width: 120,
        //     funcBody: (value, record) => (value ? this.saThresholdTypeFormat[record.saThresholdType] : ''),
        // },
        {
            title: '比较方向',
            prop: 'compareType',
            width: 100,
        },
        {
            title: '账户层次',
            prop: 'originalAccountId',
            width: 150,
        },
        {
            title: '控制类型',
            prop: 'accountControlType',
            width: 150,
        },
        {
            title: '控制账户',
            prop: 'accountControlValue',
            width: 150,
        },
        {
            title: '排除账户',
            prop: 'accountDebarValue',
            width: 120,
        },
        {
            title: '排除账户组',
            prop: 'accountGroupDebarValue',
            width: 150,
        },

        {
            title: '修改日期',
            prop: 'modifyDate',
            width: 180,
        },
        // {
        //     title: '修改时间',
        //     prop: 'modifyTime',
        //     width: 100,
        // },
        {
            title: '修改人',
            prop: 'modifyUser',
            width: 150,
        },
        {
            title: '复核人',
            prop: 'checkUser',
            width: 150,
        },
        {
            title: '复核日期',
            prop: 'checkDate',
            width: 120,
        },
        {
            title: '复核时间',
            prop: 'checkTime',
            width: 100,
        },
        {
            title: '条目来源',
            prop: 'sourceType',
            width: 100,
        },
        {
            title: '自定义分类',
            prop: 'customType',
            width: 110,
        },
        {
            title: '备注',
            prop: 'content',
            width: 150,
        },
    ];

    otherTableColumns: any[] = [
        {
            title: '排除资产单元',
            prop: 'assetCodeDebarValue',
            width: 120,
        },
        {
            title: '排除资产单元组',
            prop: 'assetGroupDebarValue',
            width: 150,
        },
        {
            title: '排除投资组合',
            prop: 'fdAcCodeDebarValue',
            width: 120,
        },
        {
            title: '排除投资组合组',
            prop: 'fdAcGroupDebarValue',
            width: 150,
        },
    ];
    paging: any = {
        total: 0,
        currentPage: 1,
        totalPage: 0,
        pageSize: 25,
    };
    loading: boolean = false;
    selectedList: any[] = [];
    selectedArrList: any[] = [];
    selectedArrListChild: any[] = [];
    sorter: any = {
        entryCode: 'descend',
    };
    selectData: any = {
        entryCode: [], // 条目编号
        precision: false, // 准确搜索
        riskCalTypes: [], // 作用范围
        entryName: '', // 风险说明
        entryStatuss: [], // 启用状态
        controlGrades: [], // 风险等级
        beginDate: '', // 生效时间
        endDate: '', // 失效时间
        accountControlValue: [], // 基金账户
        sourceType: [], // 条目来源
        entryTypes: [], // 风险类型
        entryGroups: [], // 条目组
        excludeEntryGroup: false, // 排除选中
        customType: [], // 自定义分类
        checkUserCodes: [], // 复核人
        checkTableDataDirection: '', // 复核时间
        entryRoleCode: [], // 条目角色
        RiskModifyTypes: [], // 复核事件
        modifyStatusTypes: ['1'],
        fdAcCodeControlValue: [],
        assetCodeControlValue: [],
    };
    entryCodeLits: string = '';
    dialogTitle: string = ''; // 复核弹窗标题
    dialogData: string = '';
    // lookCheck: boolean = false;
    fundGroups: any = []; // 产品组数据
    fundGroupsEnum: any = {};
    funds: any[] = []; // 产品数据
    fundsEnum: any = {};
    assets: any = [];
    assetsEnum: any = {};
    assetGroups: any = [];
    assetGroupsEnum: any = {};
    fdAcs: any = [];
    fdAcsEnum: any = {};
    fdAcGroups: any = [];
    fdAcGroupsEnum: any = {};

    cutomTypes: any = null;
    lookControl: boolean = false;
    alertControlGrade: any[] = [];
    EntryTypeList: any[] = [];
    customTypesList: any[] = [];
    EntryRoleList: any[] = [];
    accountList: any[] = []; // 基金账户
    entryGroupsList: any[] = [];
    entryColmensList: any[] = [];
    tableDataLists: any[] = [];
    ControlDirection: any[] = [];
    FNUserAccount: any[] = [];
    RiskModifyType: any[] = [];
    modifyStatusList: any[] = [];
    drawer: boolean = false;
    mutextableData: any[] = [];
    layoutDialog: boolean = false;
    selectedFieldList: any[] = [];
    entryCodeChoice: any = '';

    verification: boolean = false;
    verificationTitle: string = '';
    verificationData: string = '';
    editDatas: any = {};
    checkReason: any = ''; // 备注原因
    // 固定字段列表
    fixedFieldList: any[] = [
        { content: '条目编号', id: 'entryCode', sortable: true },
        { content: '复核状态', id: 'modifyStatus', sortable: true },
        { content: '事件', id: 'modifyType', sortable: true },
        { content: '操作', id: '', sortable: false },
    ];
    showColumns: any[] = [];
    showAllTable: boolean = false;

    // 条目来源下拉数据
    sourceTypes: any[] = [
        { dictKey: '1', dictKeyName: '本地' },
        { dictKey: '2', dictKeyName: '恒生-主动' },
        { dictKey: '3', dictKeyName: '恒生-被动' },
    ];

    saThresholdTypeFormat = {
        '0': '合规',
        '1': '警告',
        '2': '送审',
        '3': '禁止',
    };

    get userInfo(): IUserInfo {
        return UserModule.userInfo;
    }

    get urlH() {
        return '/entry';
    }
    fdAcList: any[] = [];
    async mounted() {
        if (this.SHOW_SECURITY) {
            // 资产单元
            this.assets = await awaitAxios('/asset/list/byFundCode');
            this.assetGroups = await awaitAxios('/assetGroup/list');
            this.fdAcs = await awaitAxios('/fdAc/list/byFundCode');
            this.fdAcGroups = await awaitAxios('/fdAcGroup/list');
        }
        let selectData = {
            accountControlValue: [],
            entryTypes: [],
            sourceType: [],
        };
        this.Columns.forEach(item => {
            item.id = item.prop;
            item.content = item.title;
        });
        this.SHOW_SECURITY &&
            this.otherTableColumns.forEach(item => {
                item.id = item.prop;
                item.content = item.title;
            });

        this.showColumns = this.Columns;
        this.queryLayout();
        // 监听watchEdittabes里面用到了，这里不注释掉就会请求两次
        // this.getRiskEntry(this.sorter, selectData, this.paging);
        // 产品组信息
        this.fundGroups = (await DictionConstUtil.FNFundGroup()) || [];
        // 风险等级
        this.alertControlGrade = DictionConstUtil.PojoToList(DictionConstUtil.ControlGrade);
        // 风险类型
        this.EntryTypeList = DictionConstUtil.PojoToList(DictionConstUtil.EntryType);
        // 自定义风险
        this.customTypesList = (await DictionConstUtil.FNCustomType()) || [];
        let userList = (await DictionConstUtil.FNUserAccount()) || [];
        let usersList = [];
        for (let i = 0; i < userList.length; i++) {
            usersList.push({ dictKey: userList[i].userCode, dictKeyName: userList[i].userNickName, showCode: userList[i].showCode });
        }
        this.FNUserAccount = usersList;
        // 条目角色
        this.EntryRoleList = DictionConstUtil.PojoToList(DictionConstUtil.EntryRole);
        this.RiskModifyType = DictionConstUtil.PojoToList(DictionConstUtil.RiskModifyType);
        this.modifyStatusList = DictionConstUtil.PojoToList(DictionConstUtil.modifyStatus);
        // 比较
        this.ControlDirection = DictionConstUtil.PojoToList(DictionConstUtil.ControlDirection);
        this.cutomTypes = DictionConstUtil.ListToPojo(this.customTypesList || []) || {};
        this.funds = await SGU_CACHE('FundInfoByUser', '/fundInfo/list/byUser/like', []);

        // 设置枚举 用于转义
        this.fundsEnum = this.ListToPojo('fundCode', this.funds, 'fundNameSt');
        this.fundGroupsEnum = this.ListToPojo('fundGroupCode', this.fundGroups, 'fundGroupName');
        this.assetsEnum = this.ListToPojo('assetCode', this.assets, 'assetName');
        this.assetGroupsEnum = this.ListToPojo('assetGroupCode', this.assetGroups, 'assetGroupName');
        this.fdAcsEnum = this.ListToPojo('fundAccountCode', this.fdAcs, 'fundAccountName');
        this.fdAcGroupsEnum = this.ListToPojo('fdAcGroupCode', this.fdAcGroups, 'fdAcGroupName');

        // -1 也在展示范围内
        this.fundsEnum['-1'] = '全部选择';
        this.fundGroupsEnum['-1'] = '全部选择';
        this.assetsEnum['-1'] = '全部选择';
        this.assetGroupsEnum['-1'] = '全部选择';
        this.fdAcsEnum['-1'] = '全部选择';
        this.fdAcGroupsEnum['-1'] = '全部选择';

        // 条目数据
        // let fubds = await SGU_CACHE('FundInfo', '/fundInfo/list', []);
        // let local = [];
        // for (let itme of funds) {
        //     let datas = itme.fundCode + '-' + itme.fundName;
        //     local.push();
        // }
        // 基金账户
        this.accountList = this.funds.map(item => {
            return { label: item.fundCode + '-' + item.fundName, id: item.fundCode };
        });

        this.getGroupList();
    }

    // 风险等级已选项前置
    get computedAlertControlGrade() {
        let alertControlGrade = changeOptions(this.selectData.controlGrades, this.alertControlGrade, 'dictKey');
        return alertControlGrade;
    }

    // 基金账户已选项前置
    get computedAccountList() {
        let accountList = changeOptions(this.selectData.accountControlValue, this.accountList, 'id');
        return accountList;
    }

    // 投资组合已选项前置
    get computedFilterfdAcList() {
        let filterfdAcList = changeOptions(this.selectData.fdAcCodeControlValue, this.filterfdAcList, 'fundAccountCode');
        return filterfdAcList;
    }

    // 风险类型已选项前置
    get computedEntryTypeList() {
        let EntryTypeList = changeOptions(this.selectData.entryTypes, this.EntryTypeList, 'dictKey');
        return EntryTypeList;
    }

    // 资产单元已选项前置
    get computedFilterAssetList() {
        let filterAssetList = changeOptions(this.selectData.assetCodeControlValue, this.filterAssetList, 'id');
        return filterAssetList;
    }

    // 条目来源已选项前置
    get computedSourceTypes() {
        let sourceTypes = changeOptions(this.selectData.sourceType, this.sourceTypes, 'dictKey');
        return sourceTypes;
    }

    // 条目组已选项前置
    get computedEntryGroupsList() {
        let entryGroupsList = changeOptions(this.selectData.entryGroups, this.entryGroupsList, 'dictKey');
        return entryGroupsList;
    }

    // 复核人已选项前置
    get computedUserAccount() {
        let FNUserAccount = changeOptions(this.selectData.checkUserCodes, this.FNUserAccount, 'dictKey');
        return FNUserAccount;
    }

    // 自定义分类已选项前置
    get computedCustomTypesList() {
        let customTypesList = changeOptions(this.selectData.customType, this.customTypesList, 'dictKey');
        return customTypesList;
    }

    // 复核事件已选项前置
    get computedRiskModifyType() {
        let RiskModifyType = changeOptions(this.selectData.RiskModifyTypes, this.RiskModifyType, 'dictKey');
        return RiskModifyType;
    }

    // 复核状态已选项前置
    get computedModifyStatusTypes() {
        let modifyStatusList = changeOptions(this.selectData.modifyStatusTypes, this.modifyStatusList, 'dictKey');
        return modifyStatusList;
    }

    isRed({ row }) {
        if (row.entryCode == this.entryCodeChoice) {
            return {
                backgroundColor: '#b4e4fe',
            };
        }
    }

    // 布局
    async onSubmit() {
        await this.queryLayout();
    }

    // 获取页面布局信息
    async queryLayout() {
        this.loading = true;
        const name = 'RISK_ENTRT_CHECK';
        let resList: any = await new Promise((resolve, reject) => {
            this.$axios('/tableLayout/query/' + name)
                .then((res: any) => {
                    resolve(res);
                })
                .catch(err => {
                    reject(err);
                });
        });
        if (resList) {
            if (this.SHOW_SECURITY) {
                this.selectedFieldList = JSON.parse(resList);
            } else {
                let columns = [];
                JSON.parse(resList).forEach(i => {
                    if (!['assetCodeDebarValue', 'assetGroupDebarValue', 'fdAcCodeDebarValue', 'fdAcGroupDebarValue'].includes(i.prop)) {
                        columns.push(i);
                    }
                });
                this.selectedFieldList = columns;
            }
            this.selectedFieldList.forEach(item => {
                item.title = item.content;
                item.prop = item.id;
            });
            this.loading = false;
        } else {
            this.selectedFieldList = this.SHOW_SECURITY ? this.Columns.concat(this.otherTableColumns) : this.Columns;
            this.loading = false;
        }
    }

    @Watch('selectedFieldList', { immediate: true, deep: true })
    onChangselectedFieldList() {
        this.loading = true;
        if (this.selectedFieldList.length == 0) {
            this.showColumns = this.SHOW_SECURITY ? this.Columns.concat(this.otherTableColumns) : this.Columns;
            this.loading = false;
        } else {
            let columns = this.SHOW_SECURITY ? this.Columns.concat(this.otherTableColumns) : this.Columns;
            for (let j = 0; j < columns.length; j++) {
                for (let i = 0; i < this.selectedFieldList.length; i++) {
                    if (this.selectedFieldList[i].id == columns[j].id) {
                        this.selectedFieldList[i].prop = columns[j].prop;
                        this.selectedFieldList[i].title = columns[j].title;
                        this.selectedFieldList[i].width = columns[j].width;
                        this.selectedFieldList[i].funcBody = columns[j].funcBody;
                    }
                }
            }
            this.showColumns = this.selectedFieldList;
            this.loading = false;
        }
    }

    dropdownClick(command: string): void {
        if (command === 'all') {
            this.selectedList = [];
            if (this.showAllTable) {
                this.showAllTable = false;
                this.selectedList = [];
            } else {
                this.showAllTable = true;
                let user = getUser();
                let paging = {
                    total: 0,
                    currentPage: 1,
                    totalPage: 0,
                    pageSize: 2147483647,
                };
                let sorter = {
                    entryCode: 'descend',
                };
                let riskEntryControlQuery = {};
                this.$axios
                    .post(this.urlH + '/check/entryControl/1', {
                        paging: paging,
                        sorter: sorter,
                        riskEntryControlQuery: riskEntryControlQuery,
                    })
                    .then((res: any) => {
                        let selectedList = [];
                        for (let i = 0; i < res.riskEntryCheckControls.length; i++) {
                            if (user.superuser || user.userCode !== res.riskEntryCheckControls[i].setupUserCode) {
                                selectedList.push(res.riskEntryCheckControls[i].entryCode);
                            }
                        }
                        // 考虑到复核通过全部需要用到对应数据数组，要缓存起来
                        this.table2Data = res.riskEntryCheckControls;
                        this.selectedList = selectedList;
                        this.loading = false;
                    })
                    .catch(() => {
                        this.loading = false;
                    });
            }
        }
    }

    @Watch('editableTabsValue', { immediate: true, deep: true })
    watchEdittabes() {
        if (this.editableTabsValue === '条目复核') {
            let selectData = {
                accountControlValue: [],
                entryTypes: [],
                sourceType: [],
            };
            this.getRiskEntry(this.sorter, selectData, this.paging);
        }
    }

    // 获取条目组
    getGroupList() {
        this.$axios.get('/entry/group/list').then((res: any) => {
            res = res || [];
            for (let i = 0; i < res.length; i++) {
                this.entryGroupsList.push({ dictKey: res[i].groupCode, dictKeyName: res[i].groupName });
                this.entryColmensList.push({ entryCode: res[i].groupCode, entryName: res[i].groupName });
            }
        });
    }

    // 获取复核列表
    getRiskEntry(sorter: any, selectData: any, paging: any): void {
        this.loading = true;
        this.$axios
            .post(this.urlH + '/check/entryControl/1', {
                paging: paging,
                sorter: sorter,
                riskEntryControlQuery: selectData,
            })
            .then((res: any) => {
                res.riskEntryCheckControls.map((item: any) => {
                    item.key = item.entryCode;
                    return item;
                });
                this.tableData = res.riskEntryCheckControls;
                this.table2Data = this.tableData;
                this.paging.total = res.total;
                this.paging.totalPage = res.totalPage;
                // this.controlReset();
                this.lookControl = false;
                this.onChangselectedFieldList();
                this.loading = false;
            })
            .catch(() => {
                this.loading = false;
                this.lookControl = false;
            });
    }
    // 监听关闭查询弹窗重置
    @Watch('lookControl', { immediate: true, deep: true })
    watchLookControl(newVal, oldVal) {
        if (newVal == false) {
            this.controlReset();
        }
    }

    // 查询
    selectDatas() {
        this.selectedList = [];
        this.paging.currentPage = 1;
        this.getRiskEntry(this.sorter, this.selectData, this.paging);
    }

    // 重置
    controlReset() {
        this.selectData = {
            entryCode: [], // 条目编号
            precision: false, // 准确搜索
            riskCalTypes: [], // 作用范围
            entryName: '', // 风险说明
            entryStatuss: [], // 启用状态
            controlGrades: [], // 风险等级
            beginDate: '', // 生效时间
            endDate: '', // 失效时间
            accountControlValue: [], // 基金账户
            sourceType: [], // 条目来源
            entryTypes: [], // 风险类型
            entryGroups: [], // 条目组
            excludeEntryGroup: null, // 排除选中
            customType: [], // 自定义分类
            checkUserCodes: [], // 复核人
            checkTableDataDirection: '', // 复核时间
            entryRoleCode: [], // 条目角色
            modifyStatusTypes: ['1'], // 复核状态
            RiskModifyTypes: [], // 复核事件
            fdAcCodeControlValue: [],
            assetCodeControlValue: [],
        };
        this.entryCodeLits = '';
        this.paging.currentPage = 1;
    }
    // 解析条目编号
    changEntrycode(val: any) {
        this.selectData.entryCode = [];
        this.selectData.entryCode = val.split(',');
    }

    // 处理table中的数据
    getTbalesData(data: any, props: any) {
        // 自定义风险分类
        let cutomTypes = this.cutomTypes;

        let datas = data[props];
        if (props == 'entryType') {
            // eslint-disable-next-line no-unused-expressions
            return DictionConstUtil.EntryType[datas];
        } else if (props == 'entryStatusValid') {
            if (data[props] == true) {
                let span = '<span style="color:green">启用</span>';
                return span;
            } else {
                let span = '<span style="color:red">禁用</span>';
                return span;
            }
        } else if (props == 'controlGrade') {
            return DictionConstUtil.ControlGrade[datas];
        } else if (props == 'riskCalTypes') {
            let result = '';
            for (let i = 0; i < datas.length; i++) {
                result += DictionConstUtil.RiskCalType[datas[i]] + ',';
            }
            return result;
        } else if (props == 'thresholdType1' || props == 'thresholdType2' || props == 'thresholdType3') {
            return DictionConstUtil.ThresholdType[datas];
        } else if (props == 'compareType') {
            return DictionConstUtil.CompareDirection[datas];
        } else if (props == 'originalAccountId') {
            return DictionConstUtil.RemoldOriginalAccountType[datas];
        } else if (props == 'accountControlType') {
            return DictionConstUtil.RemoldAccountControlType[datas];
        } else if (props == 'accountControlValue') {
            // 控制值
            if (datas && datas.length > 0) {
                if (String(data.originalAccountId) === '0') {
                    return (datas.map(item => `${item}(${this.fundsEnum[item]})`) || []).join(',');
                } else if (String(data.originalAccountId) === '1') {
                    return (datas.map(item => `${item}(${this.fundGroupsEnum[item]})`) || []).join(',');
                } else if (String(data.originalAccountId) === '2') {
                    return (datas.map(item => `${item}(${this.assetsEnum[item]})`) || []).join(',');
                } else if (String(data.originalAccountId) === '3') {
                    return (datas.map(item => `${item}(${this.assetGroupsEnum[item]})`) || []).join(',');
                } else if (String(data.originalAccountId) === '4') {
                    return (datas.map(item => `${item}(${this.fdAcsEnum[item]})`) || []).join(',');
                } else if (String(data.originalAccountId) === '5') {
                    return (datas.map(item => `${item}(${this.fdAcGroupsEnum[item]})`) || []).join(',');
                }
            } else {
                return datas;
            }
        } else if (props == 'accountDebarValue') {
            if (datas && datas.length > 0) {
                let fundNames = datas.map(item => `${item}(${this.fundsEnum[item]})`).join(',');
                return fundNames;
            } else {
                return datas;
            }
        } else if (props == 'accountGroupDebarValue') {
            // 排除账户组
            if (datas && datas.length > 0) {
                let fundGroupNames = datas.map(item => `${item}(${this.fundGroupsEnum[item]})`).join(',');
                return fundGroupNames;
            } else {
                return datas;
            }
        } else if (props == 'assetCodeDebarValue') {
            if (datas) {
                return datas.map(item => `${item}(${this.assetsEnum[item]})`).join(',');
            } else {
                return datas;
            }
        } else if (props == 'assetGroupDebarValue') {
            if (datas) {
                return datas.map(item => `${item}(${this.assetGroupsEnum[item]})`).join(',');
            } else {
                return datas;
            }
        } else if (props == 'fdAcCodeDebarValue') {
            if (datas) {
                return datas.map(item => `${item}(${this.fdAcsEnum[item]})`).join(',');
            } else {
                return datas;
            }
        } else if (props == 'fdAcGroupDebarValue') {
            if (datas) {
                return datas.map(item => `${item}(${this.fdAcGroupsEnum[item]})`).join(',');
            } else {
                return datas;
            }
        } else if (props == 'sourceType') {
            return DictionConstUtil.SourceType[datas];
        } else if (props == 'customType') {
            return datas ? cutomTypes[datas] : '';
        } else if (props == 'entryRoleCode') {
            if (datas != null) {
                let entryRoleCodes = datas.split(',');
                if (entryRoleCodes.length > 0 && entryRoleCodes.length === 1) {
                    return DictionConstUtil.EntryRole[datas];
                } else {
                    let name = '';
                    for (let i = 0; i < entryRoleCodes.length; i++) {
                        name += DictionConstUtil.EntryRole[entryRoleCodes[i]] + ',';
                    }
                    return name;
                }
            }
        } else if (props == 'entryRoleCode') {
            if (datas != null) {
                let entryRoleCodes = datas.split(',');
                if (entryRoleCodes.length > 0 && entryRoleCodes.length === 1) {
                    return DictionConstUtil.EntryRole[datas];
                } else {
                    let name = '';
                    for (let i = 0; i < entryRoleCodes.length; i++) {
                        name += DictionConstUtil.EntryRole[entryRoleCodes[i]] + ',';
                    }
                    return name;
                }
            }
        } else if (props == 'checkDate' || props == 'beginDate' || props == 'endDate') {
            return this.dateFormat(datas);
        } else if (props == 'modifyDate') {
            return this.dateFormat(datas) + ' ' + this.timeFormat(data['modifyTime']);
        } else if (props == 'checkTime') {
            return this.timeFormat(datas);
        } else {
            return datas;
        }
    }

    // 刷新
    resetData(): void {
        this.selectedList = [];
        this.selectDatas();
        // this.getRiskEntry(this.sorter, this.selectData, this.paging);
        this.$emit('refresh');
    }

    // 复核窗口
    reCheck(val: any): void {
        if (this.selectedList.length < 1) {
            this.yh_message_success('请选择条目');
            return;
        }
        this.selectedArrList = [];
        this.selectedArrListChild = [];
        let lists = [];
        /**
         * this.selectedList是多选框中的一维数组， this.tableData是二维数组
         * 通过一维数组中的值去查找多维数组中的数据
         * 然后通过取出的数组通过下标去获取需要的元素
         *  */

        this.selectedList.forEach(el => {
            let arrs = this.table2Data.filter(item => item.entryCode == el);
            let datas = {
                entryCode: '',
                modifyStatus: '',
                changeNo: null,
                modifytype: '',
                serialNo: null,
                modifyUserCode: null,
            };
            if (arrs.length) {
                datas.entryCode = arrs[0].entryCode;
                datas.modifyStatus = arrs[0].modifyStatus;
                datas.changeNo = arrs[0].changeNo;
                datas.modifytype = arrs[0].modifyType;
                datas.serialNo = arrs[0].serialNo;
                datas.modifyUserCode = arrs[0].modifyUserCode;
                lists.push(datas);
            } else {
                console.error('risk-control-check.vue的reCheck的循环中arrs结果长度为0');
            }
        });

        this.selectedArrList = lists;
        let superuser = getUser().superuser;
        let entryCodes = this.selectedArrList;
        if (!superuser == true) {
            let modifyUserCodeList = [];
            let createUserCodeList = [];
            entryCodes.forEach(pItem => {
                if (pItem.modifytype === '1' && pItem.modifyStatus === '1') {
                    if (pItem.createUserCode === getUser().userCode) {
                        createUserCodeList.push(pItem.entryCode);
                    }
                }
                // debugger
                if ((pItem.modifytype === '2' || pItem.modifytype === '3' || pItem.modifytype === '4') && pItem.modifyStatus === '1') {
                    if (pItem.modifyUserCode === getUser().userCode) {
                        modifyUserCodeList.push(pItem.entryCode);
                    }
                }
            });
            if (modifyUserCodeList.length > 0 && createUserCodeList.length > 0) {
                this.yh_message_warn(
                    '条目' + createUserCodeList + '复核人与创建人不可为同一人,' + '条目' + modifyUserCodeList + '复核人与修改人不可为同一人'
                );
                return;
            }
            if (modifyUserCodeList.length > 0) {
                this.yh_message_warn('条目' + modifyUserCodeList + '复核人与修改人不可为同一人');
                return;
            }
            if (createUserCodeList.length > 0) {
                this.yh_message_warn('条目' + createUserCodeList + '复核人与创建人不可为同一人');
                return;
            }
        }

        this.dialogData = val;

        this.checkReason = '';
        let selectedArrListChild = [];
        for (let i = 0; i < this.selectedArrList.length; i++) {
            if (this.selectedArrList[i].modifytype != '1') {
                selectedArrListChild.push(this.selectedArrList[i]);
            }
        }
        this.selectedArrListChild = selectedArrListChild;
        this.$axios.post(this.urlH + '/checkAllow/compare', selectedArrListChild).then((res: any) => {
            this.editDatas = res;
            this.verification = true;
            if (val === '1') {
                this.verificationTitle = '确定复核通过以下条目吗？';
                this.verificationData = '修改条目编号汇总：';
            } else if (val === '2') {
                this.verificationTitle = '确定复核拒绝以下条目吗？';
                this.verificationData = '修改条目编号汇总：';
            }
        });
    }

    // 单条复核
    reviewer(type: string, val: any) {
        // return;
        let superuser = getUser().superuser;
        if (!superuser) {
            if (getUser().userCode == val.modifyUserCode) {
                this.yh_message_warn('复核人不可为同一人');
                return;
            }
        }
        this.selectedArrList = [];
        this.selectedArrListChild = [];
        this.dialogData = type;
        this.checkReason = '';
        this.selectedArrList = [{ changeNo: val.changeNo, serialNo: val.serialNo, entryCode: val.entryCode }];
        this.selectedArrListChild = [{ changeNo: val.changeNo, serialNo: val.serialNo, entryCode: val.entryCode }];
        if (val.modifyType == '1') {
            this.verification = true;
            if (type === '1') {
                this.verificationTitle = '确定复核通过以下条目吗？';
            } else if (type === '2') {
                this.verificationTitle = '确定复核拒绝以下条目吗？';
            }
        } else {
            this.$axios.post(this.urlH + '/checkAllow/compare', this.selectedArrList).then((res: any) => {
                this.editDatas = res;
                this.verification = true;
                if (type === '1') {
                    this.verificationTitle = '确定复核通过以下条目吗？';
                } else if (type === '2') {
                    this.verificationTitle = '确定复核拒绝以下条目吗？';
                }
            });
        }
    }

    // 复核请求
    reCheckReset(): void {
        let url = '';
        if (this.dialogData === '1') {
            url = this.urlH + '/check/allow';
        } else {
            url = this.urlH + '/check/refuse';
        }
        for (let i = 0; i < this.selectedArrList.length; i++) {
            this.selectedArrList[i]['checkReason'] = this.checkReason;
        }
        this.loading = true;
        this.$axios
            .post(url, this.selectedArrList)
            .then((res: any) => {
                this.selectedList = [];
                this.loading = false;
                this.verification = false;
                if (res && res.length > 0) {
                    if (this.selectedArrList.length === res.length) {
                        this.yh_message_success('复核失败,失败编号：' + res.join(','));
                    } else {
                        this.yh_message_success('复核成功,但以下编号不能被复核：' + res.join(','));
                    }
                } else {
                    this.yh_message_success('复核成功');
                    this.getRiskEntry(this.sorter, this.selectData, this.paging);
                }
            })
            .catch(() => {
                this.selectedList = [];
                this.verification = false;
                this.loading = false;
            });
    }

    // 联合互斥
    rowClick(val: any) {
        this.$axios.get('entry/relation/check/' + val.entryCode + '/' + val.serialNo + '/' + val.changeNo).then((res: any) => {
            let b = Object.getOwnPropertyNames(res);
            if (b.length == 0) {
                return;
            } else {
                this.drawer = true;
                this.mutextableData = res.joinRiskEntryControls;
                let hc = Object.getOwnPropertyDescriptor(res, 'mutualRiskEntryControls'); // 互斥
                let lh = Object.getOwnPropertyDescriptor(res, 'joinRiskEntryControls'); // 联合
                let qt = Object.getOwnPropertyDescriptor(res, 'premiseRiskEntryControls'); // 前提
                let relationType = '';

                if (hc) {
                    relationType = '互斥';
                } else if (lh) {
                    relationType = '联合';
                } else if (qt) {
                    relationType = '前提';
                }

                this.mutextableData.forEach(element => {
                    element.relationType = relationType;
                });
            }
        });
    }

    // 分页
    currentChange(val: any) {
        // this.paging.currentPage = val;
        this.getRiskEntry(this.sorter, this.selectData, this.paging);
    }

    // 校验
    verifyInfo(val: any) {
        let newArr = [];
        newArr.push(val);
        this.loading = true;
        this.$axios
            .post(this.urlH + '/validataEntryCheckSql', newArr)
            .then((res: any) => {
                this.loading = false;
                if (res && res.length > 0) {
                    this.yh_message_success('编号：' + res.join(',') + '配置有误，具体原因请查询错误日志');
                } else {
                    this.yh_message_success('配置正确');
                }
            })
            .catch(() => {
                this.loading = false;
            });
    }

    // 打开编辑页面
    openTabs(type: string, val: any) {
        this.$nextTick(() => {
            this.entryCodeChoice = val.entryCode;
        });
        let datas: any = {};
        datas.type = type;
        datas.value = val;
        this.dispatch('ItemSetting', 'addTables', datas);
    }

    filterAssetList: any[] = [];
    filterfdAcList: any[] = [];
    time1 = null;
    filterMethodAsset(val1) {
        console.log(val1, 'val');
        const val = val1.trim();
        if (val) {
            if (this.time1) {
                clearTimeout(this.time1);
            }
            this.time1 = setTimeout(() => {
                this.filterAssetList = this.assets.filter(
                    item =>
                        item.assetCode.toUpperCase().indexOf(val.toUpperCase()) > -1 || item.assetName.toUpperCase().indexOf(val.toUpperCase()) > -1
                );
                console.log(this.filterAssetList, 'filterAssetList');
            }, 200);
        } else {
            if (this.time1) {
                clearTimeout(this.time1);
            }
            this.filterAssetList = this.assets;
        }
    }

    filterMethodFdAc(val1) {
        console.log(val1, 'val');
        const val = val1.trim();
        if (val) {
            if (this.time1) {
                clearTimeout(this.time1);
            }
            this.time1 = setTimeout(() => {
                this.filterfdAcList = this.fdAcList.filter(
                    item =>
                        item.fundAccountCode.toUpperCase().indexOf(val.toUpperCase()) > -1 ||
                        item.fundAccountName.toUpperCase().indexOf(val.toUpperCase()) > -1
                );
                console.log(this.filterfdAcList, 'filterfdAcList');
            }, 200);
        } else {
            if (this.time1) {
                clearTimeout(this.time1);
            }
            this.filterfdAcList = this.fdAcList;
        }
    }
    handleVisibleChange(state: boolean) {
        if (state && !this.filterfdAcList.length) {
            this.filterfdAcList = this.fdAcList;
        }

        if (state && !this.filterAssetList.length) {
            this.filterAssetList = this.assets;
        }
    }

    // 表格勾选框单行是否可勾选
    disabledMethod(row) {
        let user = getUser();
        return !user.superuser && user.userCode === row.setupUserCode;
    }

    thresholdTypeFormat(value, unit): string {
        // 三目运算符, unit为'%'和'万元'、'万股'的由后端处理了，不由numberFormat方法处理
        return ['%', '万元', '万股'].includes(unit) ? value : numberFormat(value.replace(/[^0-9.-]/gi, ''), unit) + unitShow(unit);
    }

    /**
     * 集合转对象2 已集合中的某个字段作为key value=对象
     */
    private ListToPojo(key: any, param: any, key2: any) {
        const pojo = {};
        for (let i = 0; i < param.length; i++) {
            pojo[param[i][key]] = param[i][key2];
        }
        return pojo;
    }
}
</script>
<style lang="scss" scoped>
.control-check {
    color: #222;
    padding: 10px;
    overflow-x: scroll;

    .check1 {
        width: 98vw;
        min-width: 900px;
        padding: 10px;
        border: 1px solid #eee;
    }

    .check2 {
        margin-top: 10px;
        width: 98vw;
        min-width: 880px;
        border: 1px solid #eee;
        height: calc(100vh - 145px);
    }

    .con-select-div {
        .divs {
            width: 640px;
            margin-top: 10px;
            position: relative;

            .divs-left {
                display: inline;
                width: 480px;

                span {
                    margin-right: 8px;
                }

                .span-left {
                    margin-left: 10px;
                }

                .divs-left-input {
                    width: 196px;
                }

                .divs-left-input1 {
                    width: 334px;
                    margin-right: 2px;
                }

                .left-input2 {
                    width: 130px;
                }
            }

            .divs-right {
                position: absolute;
                right: 0;
                display: inline;
                width: 210px;
                margin-left: 15px;
                text-align: right;

                span {
                    width: 100px;
                    margin-right: 8px;
                    text-align: right;
                }

                .ringt-input {
                    width: 130px;
                }

                .ringt-input2 {
                    width: 105px;
                }

                .ringt-input02 {
                    width: 120px;
                }
            }

            .divs-right2 {
                position: absolute;
                right: 0;
                display: inline;
                width: 210px;
                margin-left: 15px;
            }
        }
    }

    .aletr-tbale {
        width: 80%;
        padding: 10px;
        overflow: scroll;
    }
}
/deep/ .el-select__tags {
    flex-wrap: nowrap;
    overflow: hidden;
}
</style>
